package com.mzy.linear_struct.subject;

import java.util.Arrays;
import java.util.List;

/**
 * @Author: mizy3
 * @Date: 2024/06/14/下午5:15
 * @Description:
 */
public class 验证回文串 {


    public boolean isPalindrome(String s) {
        char[] str = s.toCharArray();
        int left = 0, right = str.length - 1;
        while (left <= right) {
            if (str[left] >= 32 && str[left] <= 47 || str[left] >= 58 && str[left] <= 64 || str[left] >= 91 && str[left] <= 96 || str[left] >= 123 && str[left] <= 126) {
                left++;
                continue;
            }
            if (str[right] >= 32 && str[right] <= 47 || str[right] >= 58 && str[right] <= 64 || str[right] >= 91 && str[right] <= 96 || str[right] >= 123 && str[right] <= 126) {
                right--;
                continue;
            }

            if (Character.toLowerCase(str[left]) != Character.toLowerCase(str[right])) {
                return false;
            }
            left++;
            right--;
        }
        return true;
    }

    public static void main(String[] args) {
        //    i
        // race a car
        //      j
        System.out.println(new 验证回文串().isPalindrome("ab_a"));
    }
}
